<template name="supplierTable">
    <el-table
            :data="supplierList"
            style="width: 100%"
            :row-style="{cursor:'pointer'}"
            row-key="id"
            border
            highlight-current-row
            :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
        <el-table-column
                prop="id"
                align="center"
                label="ID"
                width="50"
                >
        </el-table-column>
        <el-table-column
                prop="supplier_name"
                align="center"
                label="供货商名称"
                >
        </el-table-column>
        <el-table-column
                label="供货商图片"
                align="center"
        >
            <template scope="scope">
                <img :src="scope.row.supplier_img" width="70" height="70" v-if="scope.row.supplier_img"/>
            </template>
        </el-table-column>
        <el-table-column
                align="center"
                prop="status"
                label="运营状态"
        >
            <template slot-scope="scope">
                <span v-if="scope.row.status == 1">正常</span>
                <span v-else>冻结</span>
            </template>
        </el-table-column>
        <el-table-column
                prop="supplier_price"
                align="center"
                label="供货商收益"
        >
        </el-table-column>
        <el-table-column
                prop="user_name"
                align="center"
                label="账号"
                width="100">
        </el-table-column>
        <el-table-column
                label="操作"
                align="center"
                width="250">
            <template slot-scope="scope">
                <el-button
                        size="mini"
                        @click="handleSee(scope.$index, scope.row)">查看</el-button>
                <!--<el-button-->
                        <!--size="mini"-->
                        <!--@click="handleEdit(scope.$index, scope.row)">修改</el-button>-->
                <!--<el-button-->
                        <!--size="mini"-->
                        <!--@click="handleDelete(scope.$index, scope.row)">删除</el-button>-->
            </template>
        </el-table-column>
    </el-table>
</template>

<script>
    export default {
        name: "supplierList",
        props: ['supplierList'],
        data(){
            return{
            }
        },
        methods: {
            handleSee(index,row){
                // console.log(index, row);
                this.$router.push({
                    path: '/newSupplier',
                    query: {
                        type: 4,
                        list: row
                    }
                })
            },
            handleEdit(index, row) {
                console.log(index, row);
                this.$router.push({
                    path: '/newSupplier',
                    query: {
                        type: 2,
                        list: row
                    }
                })
            },

            handleDelete(index, row) {
                console.log(index, row);
                this.$confirm('此操作将永久删除该banner, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.operationBanner(row)
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            async operationBanner(list){
                let res = await this.$Http.operationBanner({
                    type: 3,
                    id: list.id
                })
                console.log(res)
                if(res.code == 1){
                    this.$message({
                        type: 'success',
                        message: '此banner删除成功!'
                    });
                }
                this.$emit('refreshTableFun')
            }
        }
    }
</script>
